package com.singzi.leetcode.N600;

public class T0507 {
    public static void main(String[] args) {
        Solution0507 solution0507 = new Solution0507();
        System.out.println(solution0507.checkPerfectNumber(28));
    }
}
class Solution0507 {
    public boolean checkPerfectNumber(int num) {
        int sum = 0;
        int sqrtIndex = (int) Math.sqrt(num);
        for (int i = 1; i <= sqrtIndex; i++) {
            if(num%i == 0){
                sum += i;
                sum += num/i;
            }
        }
        sum -= num;
        if(sqrtIndex*sqrtIndex == num) sum -= sqrtIndex;
        System.out.println(sum);
        return sum == num;


    }
}